package 华为OD机试真题2023.基础题;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class HJ30_找出通过车辆最多颜色 {
  public static void main(String[] args) throws FileNotFoundException {
    Scanner in = new Scanner(new File("src/main/java/华为OD机试真题2023/基础题/input/30.txt"));
    String[] sArray = in.nextLine().split(" ");
    int count = in.nextInt();
    Map<String, Integer> map = new HashMap<>();
    int max = Integer.MIN_VALUE;
    for (int i = 0; i < sArray.length; i++) {
      if (i >= count) {
        String quit = sArray[i - count];
        map.put(quit, map.get(quit) - 1);
      }
      int now = map.getOrDefault(sArray[i], 0) + 1;
      map.put(sArray[i], now);
      if (now > max) {
        max = now;
      }
    }
    System.out.println(max);
  }
}
